Skip to main content

Vietnamese ID Card Quality Check

Requirements

  • The input image size does not exceed 5 MB.

Request

Request Url

In the case that quality check is used before OCR or fraud check:

  • If the quality check result is failed, the final result only includes quality check result (no OCR or fraud check result).
  • If the quality check result is passed, the final result includes both quality check result and OCR or fraud check result.

Request Headers

ParameterRequiredDefaultDescription
api_keyYesYour api key ( get from console.fpt.ai )

Request Body

FormData contain a single image to check the quality.

ParameterRequiredDescription
imageYes

Sample Request

curl -X POST https://api.fpt.ai/vision/idr-qual/vnm -H "api-key: xxxxxx" -F "image=@path/to/image"

Response

JSON

{
"errorCode" : x,
"errorMessage" : "xxxx",
"data" : [xxxx]
}

The system is able to check the quality of a photo of old or new types of Vietnamese ID card.

After successfully sending the request, the system will return a json file that includes text information about the image quality using the format below:

  • errorCode: value is 0 if the request was successful with no error occurred
  • errorMessage: value is equal to empty string if the request was successful with no error occurred
  • data: include all information about the image quality if the request succeeds without errors or return empty list [] if an error occurs. Also included with the information returned is the probability that indicates the reliability of the returned results.

(The detail of the errors that might occure include both errorCode and errorMessage is described on Errors)

Data

{
"errorCode": 0,
"errorMessage": "",
"data": [
{
"bright_spots_score": "xxxx",
"blur_score": "xxxx",
"luminance_score": "xxxx",
"resolution": "xxxxxxxxx",
"document_area_ratio_score": "xxxx",
"final_result": {
"lowResolutionLikelihood": "unlikely",
"lowDocumentAreaRatioLikelihood": "unlikely"
"havingBrightSpotsLikelihood": "unlikely",
"blurredLikelihood": "unlikely",
"badLumimanceLikelihood": "unlikely"
}
}
]
}

The API Responses composes of 5 data fields:

FieldDescription
bright_spots_scoreProbability that the image have bright spots
blur_scoreProbability that the image is blurred
luminance_scoreLuminous intensity of the image
resolutionResolution of the image
document_area_ratio_scoreRatio of the document area in the overall area of the image
final_resultConclusion about the image quality

The final_result includes following criteria (the result of each criteria are likely/unlikely):

  • lowResolutionLikelihood: Low resolution. The minimum resolution should be 640x480 for unlikely result, otherwise likely.
  • havingBrightSpotsLikelihood: Having bright spot. The bright_spots_score should be lower than 90 for unlikely result, otherwise likely.
  • blurredLikelihood: Is blurry. The blur_score should be lower than 71 for unlikely result, otherwise likely.
  • badLumimanceLikelihood: Having bad lunimance. The luminance_score should be lower than 93 and higher than 32 for unlikely result, otherwise likely.
  • lowDocumentAreaRatioLikelihood: The ratio of document area over the image area is too small. The lowDocumentAreaRatioLikelihood should be higher than 15 (%) for unlikely result, otherwise likely.

Errors

The system uses the error codes as follows:

Error CodeMeaning
0No error -- This is a successful call, no error
1Invalid Parameters or Values! -- Wrong parameter in the request (e.g. no key or image in the request body).
3Unable to find ID card in the image -- The system cannot find the Vietnamese ID card in the image or the image is of poor quality (too blur, too dark/bright).
5No URL in the request -- The request uses the image_url key but the value is left blank.
6Failed to open the URL! -- The request uses the image_url key but the system cannot open this URL.
7Invalid image file -- The uploaded file is not an image file.
8Bad data -- The uploaded image file is corrupted or the format is not supported.
9No string base64 in the request -- The request uses image_base64 key but the value is left blank.
10String base64 is not valid -- The request uses image_base64 key but the provided string is invalid.